package com.zsk.shop.controller.app;

import com.zsk.shop.common.base.BaseResponse;
import com.zsk.shop.common.utils.HttpContext;
import com.zsk.shop.model.params.AddBankCardParams;
import com.zsk.shop.service.BankCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author Ys
 * @date 2022年02月21日 10:08
 */
@RestController
@Api(tags = "商城-银行号绑定")
@RequestMapping("/shop/bankCard")
public class ShopBankCardController {

    @Resource
    private BankCardService bankCardService;

    @ApiOperation("填写用户银行卡账户")
    @PostMapping("/addBankCardUser.do")
    public BaseResponse addBankCardUser(@RequestBody AddBankCardParams params) {
        return bankCardService.addBankCardUser(params.getBankCardId(), params.getBankNo(), params.getBankName(), params.getPhone(), params.getSubName());
    }

    @ApiOperation("用户通过卡号获取银行名称")
    @GetMapping("/getBankInfo.do")
    @ApiImplicitParam(name = "bankCardId", value = "银行卡卡号")
    public BaseResponse getBankInfo(String bankCardId) {
        return bankCardService.getBankNameByCardId(bankCardId);
    }

    @ApiOperation("用户银行卡列表")
    @PostMapping("/bankCardUserList.do")
    public BaseResponse bankCardUserList() {
        return BaseResponse.success(bankCardService.getBankCardInfo(HttpContext.getUserNo()));
    }

    @ApiOperation("删除银行卡账户")
    @GetMapping("/deletedBankCard.do")
    @ApiImplicitParam(name = "id", value = "删除编号")
    public BaseResponse deletedBankCard(Long id) {
        return bankCardService.deletedBankCard(id);
    }

    @ApiOperation("获取银行列表")
    @PostMapping("/getBankInfoList.do")
    public BaseResponse getBankInfoList() {
        return bankCardService.getBankInfoList();
    }

}
